<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios 调用方法发送请求</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body>
    <button>get</button>
    <button>post</button>
    <button>其他</button>

    <script>
        let btns = document.querySelectorAll('button');

        btns[0].onclick = async function(){
            //发送 get 类型请求 
            // let result = await axios.get(url, config);
            //                          delete 
            let result = await axios.get('http://127.0.0.1:8090/server', {
                params: {
                    a: 100,
                    b: 200
                }
            });

            console.log(result);
        }

        btns[1].onclick = async function(){
            //发送 post 类型请求
            // let result = await axios.post(url, data, config);
            //                          put patch
            let result = await axios.post('http://127.0.0.1:8090/server', {c:300, d: 400}, {params: {a: 100}});
            console.log(result);
        }
    
        btns[2].onclick = async function(){
            let result = await axios.delete('http://127.0.0.1:8090/server');
            // let result = await axios.patch('http://127.0.0.1:8090/server');
            // let result = await axios.put('http://127.0.0.1:8090/server');
            console.log(result);
        }
    </script>
</body>
</html>